
package com.probiz.estore.cart.service;


import com.probiz.estore.common.model.cart.Shoppingcart;
import com.probiz.estore.exception.CouponStateException;
import com.probiz.estore.exception.CouponUseException;
import com.probiz.estore.exception.OutOfStockException;
import com.probiz.estore.exception.ProductNoExistException;
import com.probiz.estore.exception.UnderMinimumPurchaseQuantityException;

public interface ShoppingcartManager{
	
	/**
	 * 删除所有过期的购物车，过期周期在系统参数设置
	 *  @deprecated
	 */
	public void deleteExpirationShoppingcarts();

	/**
	 * 添加普通商品进购物车
	 * (默认的spring-service配置中，manager的add*方法要求创建数据库transaction，这里的方法名称特意绕开add*约束)
	 * @param shoppingcart
	 * @param productSkuCode	商品的sku code
	 * @param childSkuCodes		商品相关配件的sku code
	 * @param quantity			数量
	 * @return
	 * @throws OutOfStockException 						如果商品库存不足将抛出异常
	 * @throws UnderMinimumPurchaseQuantityException 	如果超过商品最低购买量将抛出异常
	 */
	public boolean putProductsToCart(Shoppingcart shoppingcart, String productSkuCode, String[] childSkuCodes, Integer quantity) 
	throws OutOfStockException, UnderMinimumPurchaseQuantityException, ProductNoExistException;

	/**
	 * 批量设置购物车商品项的购买数量
	 * @param shoppingcart
	 * @param productSkuCodes	商品的sku code数组
	 * @param quantitys			数量数组
	 * @return
	 * @throws OutOfStockException 						如果商品库存不足将抛出异常
	 * @throws UnderMinimumPurchaseQuantityException 	如果少于商品最低购买量将抛出异常
	 */
	public boolean changeQuantitys(Shoppingcart shoppingcart, String[] productSkuCodes, Integer[] quantitys) 
	throws OutOfStockException, UnderMinimumPurchaseQuantityException;
	
	/**
	 * 更新购物车项的数量
	 * (默认的spring-service配置中，manager的update*方法要求创建数据库transaction，这里的方法名称特意绕开update*约束)
	 * @param shoppingcart
	 * @param productSkuCode
	 * @param quantity
	 * @return
	 * @throws OutOfStockException 						如果商品库存不足将抛出异常
	 * @throws UnderMinimumPurchaseQuantityException 	如果少于商品最低购买量将抛出异常
	 */
	public boolean changeQuantity(Shoppingcart shoppingcart, String productSkuCode, Integer quantity) 
	throws OutOfStockException, UnderMinimumPurchaseQuantityException;
	
	/**
	 * 删除购物车中的普通商品项
	 * (默认的spring-service配置中，manager的delete*方法要求创建数据库transaction，这里的方法名称特意绕开delete*约束)
	 * @param shoppingcart
	 * @param productSkuCode
	 * @return
	 */
	public boolean delProductItem(Shoppingcart shoppingcart, String productSkuCode);
	
	/**
	 * 删除购物车中的礼品卷项
	 * (默认的spring-service配置中，manager的delete*方法要求创建数据库transaction，这里的方法名称特意绕开delete*约束)
	 * @param shoppingcart
	 * @param shoppingcartItemGcId
	 * @return
	 */
	public boolean delGiftCertificateItem(Shoppingcart shoppingcart, String shoppingcartItemGcId);
	
	/**
	 * 清空购物车
	 * @param shoppingcart
	 * @return
	 */
	public boolean clearShoppingcart(Shoppingcart shoppingcart);
	
	/**
	 *不使用优惠券
	 * @param couponNo 优惠券号码
	 */
	public boolean useCoupon(Shoppingcart shoppingcart, String couponNo) throws CouponStateException, CouponUseException;
	
	public boolean unuseCoupon(Shoppingcart shoppingcart);
	
}
